
using Core.SimpleTemp.Application;
using Core.SimpleTemp.Common;
using Core.SimpleTemp.Common.Authorization;
//using Core.SimpleTemp.Common.Core.Repository.Internal.Data;
using Core.SimpleTemp.Common.PagingQuery;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Mvc.Api.Internal;
using Core.SimpleTemp.Repositories.Internal;
using Core.Toolkit.Core;
using Core.Toolkit.Core.Api;
using Core.Toolkit.Core.Application;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Core.SimpleTemp.Mvc.Api.Sys
{
    /// <summary>
    /// SysDepartmentDuty
    ///</summary>
    [ApiExplorerSettings(GroupName = "Sys")]//swagger分类标签
    [Route("api/[controller]")]//路由说明
    [EnableCors("any")]//跨域规则
    [ApiController]//APi标识Controller
    public class SysDepartmentDutyController : CoreApiController
    {
        private readonly SysDepartmentDutyService _service;
        /// <summary>
        /// SysDepartmentDuty
        ///</summary>
        public SysDepartmentDutyController(SysDepartmentDutyService service)
        {
            _service = service;
        }

        #region 基础增删改查
        /// <summary>
        /// 查询
        ///</summary>
        /// <param name="pagingQueryModel"></param>
        /// <returns></returns>

        [HttpPost("GetList")]

        public async Task<IActionResult> GetList(PagingModel<SysDepartmentDutyDto> pagingQueryModel)
        {
            IPageModel<SysDepartmentDutyDto> result;
            var lpom = _service.GetLoadPageOffsetModelAuto(pagingQueryModel);
            result = await _service.LoadPageOffsetAsync(lpom);
            return this.JsonSuccess(result);
        }

        /// <summary>
        /// 添加/修改
        ///</summary>
        /// <param name="dto"></param>
        /// <returns></returns>

        [HttpPost("Save")]
        [PermissionFilter(nameof(SysDepartmentDutyController) + "_" + nameof(SysDepartmentDutyController.SaveAsync))]
        public async Task<IActionResult> SaveAsync(SysDepartmentDutyDto dto)
        {
            //添加
            if (Equals(dto.Id, Guid.Empty))
            {
                await _service.InsertAsync(dto);
                return this.JsonSuccess(string.Empty);
            }
            else
            {
                await _service.UpdateAsync(dto);
                return this.JsonSuccess(string.Empty);
            }
        }

        /// <summary>
        /// DeleteMuti
        ///</summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost("DeleteMuti")]
        public async Task<IActionResult>
            DeleteMutiAsync([FromBody]Guid[] ids)
        {

            await _service.DeleteBatchAsync(ids);
            return this.JsonSuccess();
        }


        /// <summary>
        /// 根据ID获取信息
        ///</summary>
        /// <param name="id"></param>
        /// <returns></returns>

        [HttpGet("Get")]
        public async Task<IActionResult> Get(Guid id)
        {
            var model = await _service.GetAsync(id);
            return this.JsonSuccess(model);
        }
        #endregion

        /// <summary>
        /// 根据部门id获取职务
        /// </summary>
        /// <param name="SysDepartmentID"></param>
        /// <returns></returns>
        [HttpGet("GetDuty")]
        public async Task<IActionResult> GetDutyListBySysDepartmentID(Guid SysDepartmentID)
        {
            //var list =  await _service.GetDutyListBySysDepartmentIDAsync(SysDepartmentID);
            return this.JsonSuccess();
        }


       
    }
}
